package com.sky.controller.admin;

import com.sky.dto.DishDTO;
import com.sky.mapper.DishMapper;
import com.sky.result.Result;
import com.sky.service.DishService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 *  菜品接口
 */
@RestController
@RequestMapping("/admin/dish")
@Slf4j
@Api(value = "菜品接口")
public class OwnerDishController {

    @Autowired
    private DishMapper dishMapper;

    @Autowired
    private DishService dishService;


    @ApiOperation("新增菜品")
    @PostMapping("/add")
    public Result addDish(@RequestBody DishDTO dishDTO) {
        log.info("新增菜品请求：{}", dishDTO);
        // 新增菜品和对应的口味
        dishService.savaWithFlavor(dishDTO);

        return Result.success();
    }

}
